YAHOO.namespace('springmole');

(function () {

	var Event = YAHOO.util.Event,
		Dom = YAHOO.util.Dom;
	
	YAHOO.springmole.HttpManager = function () {
		
	};
	YAHOO.springmole.HttpManager.prototype = {
		
		init: function () {
			this.createEvent('requestEvent');
			this.createEvent('successEvent');			
		},
		
		createYUIConnectCallBack: function (callback) {
			if (!callback.argument) {
				callback.argument = [];
			}
			
			callback.argument.httpManager = this;
			
			return {
				success: function (o) {
					var resultDom = o.responseXML;
					var resultStatusElement = resultDom.getElementsByTagName('ResultStatus')[0];
					var success = resultStatusElement.attributes.getNamedItem('success').value;
					if (success && success == 'true') {
						callback.success(o, resultDom.getElementsByTagName('ResultData')[0]);
						
						o.argument.httpManager.fireEvent('successEvent', 'Success');
					} else {
						callback.error(o, resultStatusElement);
					}
				},

				failure: function (o) {
					if (!callback.failure(o)) {
						handleFailure(o);
					}
				},

				scope: callback.scope,
				
				argument : callback.argument
			};

		},
				
		executeRequest: function (formAttributeMap, callback) {
			
		}
	};
		
	YAHOO.lang.augmentProto(YAHOO.springmole.HttpManager , YAHOO.util.EventProvider);

	YAHOO.springmole.HttpManager = new YAHOO.springmole.HttpManager();
	YAHOO.springmole.HttpManager.init();
	
})();